<%@ page language="java" contentType="text/html; charset=EUC-KR"
	pageEncoding="EUC-KR"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
	<h1>Department Board</h1>
	<div class="dept_board_div">
		<table id="dept_table">
			<tr>
				<th>No</th>
				<th>Title</th>
				<th>Writer</th>
				<th>Date</th>
				<th>Hit</th>
			</tr>
			<c:set var="date" value="<%=new java.util.Date()%>" />
			<c:forEach var="board" items="${boardList}">
				<tr>
					<td>${board.deptBoardNo}</td>
					<td class="left">
					<a onclick="dept_board_contents(${board.boardNo},${pageNum})">${board.title}[${board.commentCount }]</a></td>
					<td>${board.name}</td>
					<td><c:choose>
							<c:when
								test="${board.writeDate.getMonth() == date.getMonth()
										&& work.workStartTime.getDate() == date.getDate() }">
								<fmt:formatDate value="${board.writeDate}" pattern="hh:mm:ss" />
							</c:when>
							<c:otherwise>
								<fmt:formatDate value="${board.writeDate}" pattern="YYYY/MM/dd" />
							</c:otherwise>
						</c:choose></td>
					<td>${board.readCount}</td>
				</tr>
			</c:forEach>
		</table>
		<div id="paging">
			<img id="paging_prev" src="resources/images/page-arrow-left.jpg" />
			<c:forEach var="i" begin="1" end="${(boardCount / 10) + 1 }">
				<c:choose>
					<c:when test="${i == pageNum }">
						<a class="onclick"> ${i } </a>
					</c:when>
					<c:otherwise>
						<a onclick="dept_board_list_with_num(${i})"> ${i } </a>
					</c:otherwise>
				</c:choose>
			</c:forEach>
			<img id="paging_next" src="resources/images/page-arrow-right.jpg" />
		</div>
		<script>
		$(document).ready(function(){
			var pageNum = ${pageNum};
			var lastPage =parseInt("${(boardCount / 10) + 1 }");
			
			if(pageNum != 1){
				$('#paging_prev').unbind('click');
				
				$('#paging_prev').click(function(){
					dept_board_list_with_num(pageNum-1);
				});
			}
			
			if(pageNum != lastPage){
				$('#paging_next').unbind('click');
				
				$('#paging_next').click(function(){
					dept_board_list_with_num(pageNum+1);
				});
			}
		});
	</script>

		<input type="button" value="Write" id="write_btn" class="btn" onclick=deptBoardWrite()>
	</div>
